// 运动记录的次数
const { DataTypes } = require("sequelize");
const sequelize = require("../config/sequelize");
const User = require("./user");
const Sports = require("./sports");

const SportsUseNum = sequelize.define(
  "SportsUseNum",
  {
    num: {
      type: DataTypes.INTEGER,
      defaultValue: 0,
      comment: "运动被记录次数",
    },
  },
  {
    sequelize: sequelize,
    tableName: "sportsUseNum",
    underscored: true, //显示在数据库字段为下划线
    paranoid: true, // 软删除，调用destroy不会删除模型，而是设置deletedAt时间戳
  }
);



SportsUseNum.belongsTo(Sports, {
  constraints: false,
  foreignKey: "sportsId",
  as: "sports",
});
SportsUseNum.belongsTo(User, {
  constraints: false,
  foreignKey: "userId",
  as: "user",
});

module.exports = SportsUseNum;